/ Assembly List / LJCNetCommon / HTMLBuilder / Begin

Namespace - LJCNetCommon


Parameters
name - The element name.
textState - The current text state values.
attribs - The element attributes.
addIndent - Indicates if the element can be indented.
childIndent - Indicates if the child elements should be indented.

Returns

The added element begin tag.

Syntax

C#
public String Begin(String name, TextState textState, Attributes attribs = null, Boolean addIndent = True, Boolean childIndent = True)

Appends the element begin tag.

Remarks

Begin() is an "Append" method. It creates the element opening tag with GetCreate() and adds it to the builder. The appended text does not end with a new line. This allows for additions after the text.
The added text will start with a new line if the builder text already has a value.

Example

C#
// Root Method Begin
var textState = new TextState();

// Defaults: IndentCharCount = 2, LineLimit = 80, WrapEnabled = false.
var hb = new HTMLBuilder(textState);

var attribs = hb.StartAttribs();

// Example Method:
// Starts the text with a newline if the builder already has text
// and param allowNewLine = true and builder text does not end with
// a newline.
// The text begins with the current indent string if param
// addIndent = true.
// Defaults: addIndent = true, allowNewLine = true.
hb.Begin("html", textState, attribs);

hb.End("html", textState);
var result = hb.ToString();

// result:
// <html lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\">
// </html>

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.